export default{
	//购物车数量
	cartNum(state){
		let cart=state.cart;
		if((cart==undefined)||(cart==null)) return 0;
		let num=0;
		cart.forEach(item=>{
				num+=item.num;
		})
		return num;
	},
  //计算总价
  cartTotal(state){
    let cart=state.cart;
    if((cart==undefined)||(cart==null)) return 0;
    let total=0;
    cart.forEach(item=>{
      if (item.selected){
        total+=item.price*item.num;
      }
    })
    return total;
  }


}
